package com.stone.controller;

import com.stone.model.EmailRequest;
import com.stone.service.EmailService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class EmailController {

    @Autowired
    EmailService emailService;

    @PostMapping("sendEmail")
    @ApiOperation(value = "发送普通邮件", notes = "")
    public void sendEmail() {
        emailService.sendSimpleEmail(EmailRequest.builder().build());
        System.err.println("Send Email Success.");
    }

    @PostMapping("sendFileEmail")
    @ApiOperation(value = "发送带附件的邮件", notes = "")
    public void sendFileEmail(){
        emailService.sendAttachmentsMail(EmailRequest.builder()
                .from("18108402266@163.com")
                .to("2574602049@qq.com")
                .subject("发送附件")
                .content("<a href='https://blog.csdn.net/'>你好，欢迎注册网站，请点击链接激活</a>")
                .filePath("G:\\壁纸\\0d523ee118905e41cd.jpg")
                .build());
    }

}
